/**
    ATClab - scriptable Air Traffic Control simulations.
    Copyright (C) 2010 openatclab@gmail.com

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
**/

#ifndef __ATC_ROUTESPRITE_HDR__
#define __ATC_ROUTESPRITE_HDR__


#include <q3canvas.h>
//Added by qt3to4:
#include <Q3PointArray>

#include "canvas_types.h"
#include <stdexcept>


namespace atc{


	/*!
	 * \struct routesprite_error
	 */
	struct routesprite_error : public std::runtime_error{
		routesprite_error(const std::string& msg) 
			:std::runtime_error(msg)
		{}
	};


	/*!
	 * \typedef CanvasLine
	 */
	typedef std::pair<QPoint, QPoint>CanvasLine;


	/*!
	 * \class atc::RouteSprite atc_routesprite.h
	 */
	class RouteSprite : public Q3CanvasPolygonalItem {

	public: 
		RouteSprite(Q3Canvas *);
		~RouteSprite();

		void set_points(Q3PointArray);

	public: // [virtual]
		int rtti() const { return CanvasItem::RTTI_ROUTE; }

		Q3PointArray areaPoints() const;
		void drawShape( QPainter & );

	private:
		void reset_outline();
		CanvasLine offset_line(	const QPoint &, const QPoint &, int );

	private:
		Q3PointArray _vertices;
		Q3PointArray _outline;

	};

};

#endif
